import vue from 'vue'
import vuex from 'vuex'

vue.use(vuex);

const state={
    BreadcrumbItem:[],
    LoadShowType: false,
    ActionInfo: { Account: '', list: [] },
};
const mutations={
    updateBreadcrumb(state, msg) {//更新面包屑
        state.BreadcrumbItem=[];
        state.BreadcrumbItem.push(msg);
    },
    setActionList(state, msg) {
        state.ActionInfo.Account = msg.account;
        for (var i = 0; i < msg.list.length; i++) {
            if (msg.list[i].CtrlUrl == msg.path) {
                state.ActionInfo.list.push(msg.list[i]);
            }
        }
    },
    desBreadcrumb(state, msg) {//清空面包屑
        state.BreadcrumbItem=[];
    },
    loadingShow(state){//显示加载动画
        state.LoadShowType=true;
    },
    loadingHide(state){//隐藏加载动画
        state.LoadShowType=false;
    }
}
const actions = {
  updateBreadcrumb: ({ commit }, BreadcrumbItem) => commit('updateBreadcrumb', BreadcrumbItem),
  desBreadcrumb: ({ commit }) => commit('desBreadcrumb'),
  loadingShow:({ commit }) => commit('loadingShow'),
  loadingHide:({ commit }) => commit('loadingHide'),
  setActionList: ({ commit }, ActionList) => commit('setActionList', ActionList)
}
export default new vuex.Store({
    state,
    mutations,
    actions
});
